package com.example.comiccenter.controller;


import com.example.comiccenter.domain.Carousel;
import com.example.comiccenter.service.CarouselService;
import com.example.comiccenter.utils.ResultData;
import com.example.comiccenter.utils.SearchBean;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/carousel")
public class CarouselController {

    @Resource
    private CarouselService carouselService;


    //分页查询
    @PostMapping("/getAllCarousel")
    public ResultData selectPage(@RequestBody SearchBean<Carousel> searchBean){
        System.out.println("查询carousel");
        return carouselService.getAllCarousel(searchBean);
    }

    //添加carousel
    @PostMapping("/addCarousel")
    public ResultData addcarousel(@RequestPart Carousel carousel, MultipartFile picture){
        return carouselService.addCarousel(carousel,picture);
    }

    //删除carousel
    @PostMapping("/deleteCarousel")
    public ResultData deletecarousel(@RequestBody Carousel carousel){
        System.out.println("删除carousel："+carousel);
        return carouselService.deleteCarousel(carousel);
    }

    //更新carousel
    @PostMapping("/updateCarousel")
    public ResultData updatecarousel(@RequestPart Carousel carousel, MultipartFile picture){
        System.out.println("修改carousel："+carousel);
        return carouselService.updateCarousel(carousel,picture);
    }
}
